#include <QtGui/QApplication>
#include "mainwindow.h"
#include "QTextCodec"
#include <QtSql>
int main(int argc, char *argv[])
{


    QTextCodec *codec = QTextCodec::codecForName("UTF-8");
    QTextCodec::setCodecForLocale(codec);
    QTextCodec::setCodecForCStrings(codec);
    QTextCodec::setCodecForTr(codec);

    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    db.setDatabaseName("CT12");
    if(!db.open())
    {
        qDebug()<<"open db failed!!!!";
        return false;
    }
    else
    {
        qDebug()<<"open db success!!!!";
    }
    QSqlQueryModel query;
    query.setQuery("SELECT * FROM password");
    int data = query.data(query.index(0,1)).toInt();
    qDebug()<<"data:"<<data;
    query.setQuery("SELECT max(user) FROM password");
    int data1 = query.data(query.index(0,0)).toInt()+1;
    qDebug()<<"data1:"<<data1;
    //query.setQuery(QString("INSERT INTO password(user,passwd)""VALUES(%1,2222222)").arg(data1));
    QSqlQuery xx;
    xx.exec("SELECT * FROM password");
    while(xx.next())
    {
        int i = xx.value(0).toInt();
        int j = xx.value(1).toInt();
        qDebug()<<"i,j"<<i<<j;
    }


//    QSplashScreen *splash=new QSplashScreen;
////    splash->showMessage(QObject::tr("程序加载中，请稍后。。。。。。"),Qt::AlignCenter,Qt::white);
//    splash->setPixmap(QPixmap(":image/res/1.png"));
//    splash->setDisabled(true);
//    splash->show();

    QApplication a(argc, argv);
    MainWindow w;
    w.show();
//    splash->finish(&w);

    return a.exec();
}
